#ifndef GRAPHS_H
#define GRAPHS_H

#include <QWidget>
#include <QTimer>
#include "qcustomplot.h"

namespace Ui {
class Graphs;
}

class GraphsData :public QObject
{
    Q_OBJECT
public:
    QString Name       = nullptr;
    float   *MultipNum = nullptr;
    int16_t *value     = nullptr;
};

class Graphs : public QWidget
{
    Q_OBJECT

public:
    explicit Graphs(QWidget *parent = nullptr);
    ~Graphs();
    void    GiveMeList(QVector<GraphsData*> list);

private:        //func
    void    UiConstr();
    void    SingalsToSlots();
    void    NewLine(QString name);
    int     FindGrapFromName(QString Name, QVector<GraphsData *> list);
    QListWidget *CreateWidget(QString title);

private:        //var
    Ui::Graphs  *ui;
    QTimer      *UpdateTimer;
    QListWidget *AddWidget = nullptr;
    QListWidget *DelWidget = nullptr;
    bool        Started = false;

    QVector<GraphsData*> AddedGraphsList;                //已添加项
    QVector<GraphsData*> TotalGraphsList;                //全部可添加项

signals:


private slots:
    void on_Update();
    void on_btnStart_clicked();
    void on_btnAdd_clicked();
    void on_btndel_clicked();
};

#endif // GRAPHS_H
